document.addEventListener("keydown", function(event) {
    if (event.keyCode == '32') {
        console.log('space >> fire backbutton');
        var event = new CustomEvent("backbutton", { "detail": "Symulacja eventu z phonegap.js" });
        document.dispatchEvent(event);
    }
}, false);
console.log('phonegap simulate back button event');

setTimeout(function () {
    
    // Create the event
    var event = new CustomEvent("deviceready", { "detail": "Symulacja eventu z phonegap.js" });

    // Dispatch/Trigger/Fire the event
    document.dispatchEvent(event);
    
    console.log('phonegap dispatched deviceready event');
}, 2000);


/**
 * windows phone fixes
 */
if(typeof window.console === "undefined")
{
	window.console = {
        log : function(str){ 
            window.external.Notify(str);
        }
    };
}
window.onerror=function(e, url, lineNumber)
{
	console.log("ERROR! : " +url + "(" + lineNumber + ") : " + JSON.stringify(e));
};
console.log("Installed console ! ");